package com.drpclub.gamebackend.bean;

import com.drpclub.gamebackend.common.utils.DrpUtils;
import com.drpclub.gamebackend.common.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * @author dongruipeng
 * @Descrpition
 * @date 2019year 12month04day  14:26:32
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@ApiModel
public class User implements Serializable {
    @NotEmpty(message = "用户名不能为空")
    private String username;
    @NotEmpty(message = "密码不能为空")
    private String password;
    private String nickname;
    @Size(min = 3, max = 5, message = "性别不能为空")
    private String gender;
    @Min(value = 0)
    private int level;
    @Min(value = 0)
    private long exp;
    @Email(message = "请输入正确的邮箱格式")
    private String email;
    private String headImage;
    private String token;


    public User setToken(String token) {
        this.token = token;
        return this;
    }

    public User resetPassword() {
        this.password = null;
        return this;
    }

    public void setHeadImage(String headImage) {
        this.headImage = FileUtils.fullFilePath(headImage);
    }
}
